//
//  ImageMO.m
//  Words2
//
//  Created by Mathieu Tozer on 7/09/06.
//  Copyright 2006 __MyCompanyName__. All rights reserved.
//

#import "ImageMO.h"


@implementation ImageMO

-(NSImage *)image{
	NSData *imageData; //not doing caching
	imageData = [self valueForKey:@"imageData"];

	if( imageData != nil){
		imageCache = [[NSKeyedUnarchiver unarchiveObjectWithData:imageData] retain];
	}
	return imageCache;
	
}

-(void)setImage:(NSImage *)newImage{
	if (imageCache != newImage){
		[imageCache release];
		
		if(newImage == nil){
			NSLog(@"newImagesArray was nil");
		}
		
		//cache and archive in managedObject.
		imageCache = [newImage retain];
		NSData *imagesBlobData = [NSKeyedArchiver archivedDataWithRootObject:newImage];
		[self setValue:imagesBlobData forKey:@"imageData"];
	}
}


@end
